# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=gnupg1
pkgver=1.4.23
pkgrel=0
pkgdesc="GNU Privacy Guard 1 - a PGP replacement tool"
url="http://www.gnupg.org/"
arch="all"
license="GPL"
depends="pinentry"
makedepends="curl-dev libassuan libksba-dev libgcrypt-dev libgpg-error-dev
	zlib-dev libassuan-dev"
subpackages="$pkgname-doc"
provides="gnupg=$pkgver-r$pkgrel"
replaces="gnupg"
source="https://www.gnupg.org/ftp/gcrypt/gnupg/gnupg-$pkgver.tar.bz2"

# secfixes:
#   1.4.23-r0:
#     - CVE-2017-7526
#   1.4.22-r1:
#     - CVE-2018-12020

builddir="$srcdir/gnupg-$pkgver"
prepare() {
	default_prepare
	cd "$builddir"

	# Fix PIC definitions
	sed -i -e 's:PIC:__PIC__:' \
		mpi/i386/mpih-add1.S \
		mpi/i386/mpih-sub1.S \
		intl/relocatable.c \
		|| return 1
}

build() {
	cd "$builddir"
	export CFLAGS="$CFLAGS -g"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-nls \
		--enable-noexecstack \
		|| return 1
	make || return 1
}

package() {
	cd "$builddir"
	make -j1 DESTDIR="$pkgdir" install
}

doc() {
	default_doc
	provides="gnupg-doc=$pkgver-r$pkgrel"
}

sha512sums="78dc52a2010202a4afc8814b29fda657a6c9fe230d5e7db11ae040edd2b0ca819e1baa4dbd6c0d04d36cd353df484e83f52d17759d2891c2cf7025c0b5d36612  gnupg-1.4.23.tar.bz2"
